import lp_state_genaration
import pandas as pd
import csv
import numpy as np

f = open("lp_state.csv", encoding="utf-8")
df = pd.read_csv(f)
# data = data.to_dict(orient = 'record')
data = df.apply(pd.to_numeric, errors='coerce')
array1=data.values
# print(array1.shape)
lp_num = np.zeros((500,9))
cpu_usage=np.zeros((500,9))
mem_usage=np.zeros((500,9))
for j in range(500):
    locals()["order" + str(j)]=np.zeros((9,100))

orderx=np.zeros((500,9,100))
# print(lp_num[0][0]+1)
for i in range(100):
    for j in range(500):
        for k in range(9):

            if data['vm_loc%s'%i].values[j]==k:
                lp_num[j][k]=lp_num[j][k]+1
                cpu_usage[j][k] += data['cpu%s'%i].values[j]
                mem_usage[j][k] += data['mem%s' % i].values[j]
                locals()["order" + str(j)][k][i] +=1
# print(np.sum(order0,axis=1))
# for j in range(500):
#     for i in range (100):
#         for k in range (9):
#             if data['vm_loc%s' % i].values[j] == k:
#                 order[j][k][i]+=1


# print(order[:,0,0])
# al=np.concatenate([cpu_usage,mem_usage,lp_num],axis=1)
# df_lp_num=pd.DataFrame(lp_num,columns=['lp_number0', 'lp_number1', 'lp_number2', 'lp_number3', 'lp_number4', 'lp_number5', 'lp_number6','lp_number7', 'lp_number8' ])
# print(df_lp_num)
# df4=pd.DataFrame(al,
#              columns=['cpu_percent0', 'cpu_percent1', 'cpu_percent2', 'cpu_percent3', 'cpu_percent4', 'cpu_percent5',
#                       'cpu_percent6', 'cpu_percent7', 'cpu_percent8', 'mem_percent0', 'mem_percent1', 'mem_percent2',
#                       'mem_percent3', 'mem_percent4', 'mem_percent5', 'mem_percent6', 'mem_percent7', 'mem_percent8','lp_number0', 'lp_number1', 'lp_number2', 'lp_number3', 'lp_number4', 'lp_number5', 'lp_number6',
#                       'lp_number7', 'lp_number8' ])
# df4.to_csv('vm_state.csv')







